package client.comm.baoding.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import client.comm.baoding.ui.MainActivity
import client.comm.baoding.ui.TabOne2Activity

class MeBroadcast : BroadcastReceiver() {

    companion object {
        const val MAIN_SWITCH_TAB = "zwlst.main.switch"
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        intent?.action.let {
            if (it == MAIN_SWITCH_TAB) {
                if (context is MainActivity) {
                    intent?.getIntExtra("tabIndex", -1)?.let {
                        context.switchTab(it)
                    }
                } else if (context is TabOne2Activity) {
//                    context.startActivity(Intent(MAIN_SWITCH_TAB).apply {
//                        putExtra("tabIndex", 2)
//                    })
                    context.finish()
                }

            }
        }
    }
}